import type { Discipline } from './models'
import axios from 'axios'

export async function getKnowledgeGraphData() {
  try {
    // 从本地 JSON 文件加载数据
    const response = await axios.get('/data.json')
    const nodes = response.data.nodes
    const links = response.data.links
    const categories = response.data.categories
    const data = new Map<string, Discipline>()
    for (const [key, value] of Object.entries(response.data.original_data)) {
      data.set(key, value as Discipline)
    }
    return { nodes, links, categories, data }
  } catch (error) {
    console.error('Failed to load graph data from local JSON file:', error)
    throw error
  }
}
